﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Supervise_LookZBRecourd : System.Web.UI.Page
{
    string PWZBRProjectid;
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            PWZBRProjectid = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["projectid"]));
            showGridView();
        }
        else
        {
            Response.Write("<script>window.location.href='../HomePage/Default.aspx'</script>");

        }
    }

    public void showGridView()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "bidprice";
        dbPage.Key = "Bidid";
        dbPage.Where = strConditions;                        //
        dbPage.SelectField = "goodsid,ProductCode,ProductName,Outlookc,IsNull(Unit,'')+'/'+IsNull(PackUnit,'') As Pack1,Medicinemodel,goodsname,FactoryUserCode,factor,scname,smprice,spprice,Convert(numeric(20,2),BidPrice) as BidPrice,IsNull(bidprice,0)/factor as BidPriceMin,QualityLevels,TBUserCode,TBRNAME,case status when '0' then '限价' when '1' then '竟价' when '2' then '不竞不议' when '3' then '备案采购' end as status";                             //可以不设，默认为“*”

        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 20;                                                //Request.QueryString["PS"]);
        dbPage.OrderBy = "ProductName,Outlookc,Medicinemodel,Bidid";
        System.Data.IDataReader dr = dbPage.ExecuteReader(60);
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        db.Close();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键


    }

    public string fctConditions()
    {
        string ProductCode, ProductName, NameTB, UserCodeTB, NameSC, UserCodeSC, Goodsid;
        ProductCode = txtProductCode.Text.Trim();
        ProductName = txtProductName.Text.Trim();
        NameTB = txtNameTB.Text.Trim();
        UserCodeTB = txtUserCodeTB.Text.Trim();
        NameSC = txtNameSC.Text.Trim();
        UserCodeSC = txtUserCodeSC.Text.Trim();
        Goodsid = goodsidtext.Text.Trim();
        string strtemp = "";
        strtemp = " Projectid=" + PWZBRProjectid + " And checkstatus=1 and IsBid=1 And BidPrice is not Null  And";
        if (ProductCode != "")
        {
            strtemp += " ProductCode like '%" + ProductCode + "%' And";
        }
        if (ProductName != "")
        {
            strtemp += " ProductName like '%" + ProductName + "%' And";
        }
        if (NameTB != "")
        {
            strtemp += " TBRNAME like '%" + NameTB + "%' And";
        }
        if (UserCodeTB != "")
        {
            strtemp += " TBUserCode like '%" + UserCodeTB + "%' And";
        }
        if (NameSC != "")
        {
            strtemp += " scname like '%" + NameSC + "%' And";
        }
        if (UserCodeSC != "")
        {
            strtemp += " FactoryUserCode like '%" + UserCodeSC + "%' And";
        }
        if (Goodsid != "")
        {
            strtemp += " Goodsid like '%" + Goodsid + "%' And";
        }
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }

        return strtemp;

    }

}
